//
//  YZNetworkManager+Suggestion.m
//  YZMicroStock
//
//  Created by wangminhong on 16/4/7.
//  Copyright © 2016年 cqjr. All rights reserved.
//

#import "YZClient+Suggestion.h"

@implementation YZNetworkManager (Suggestion)

- (void)fetchSuggestionListWithPage:(NSInteger)page andPageSize:(NSInteger)pageSize andEndTime:(NSString *)endTime success:(void (^)(NSURLResponse *, id))success failure:(void (^)(NSError *))failure{
    
    NSDictionary *params = @{@"page":@(page), @"pageSize":@(pageSize), @"timeEnd":endTime,COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE};
    
    [self.mainNetwork cq_noCachePOST: URL_FOR_FETCH_SUGGESTION_LIST parameters: params
                             success:^(NSURLSessionDataTask *task, id responseObject) {
                                 if (success) {
                                     success(task.response, responseObject);
                                 }
                             } failure:^(NSURLSessionDataTask *task, NSError *error) {
                                 if (failure) {
                                     failure(error);
                                 }
                             }];
}

- (void)submitSuggestionWithContent:(NSString *)content andType:(NSString *)type success:(void (^)(NSURLResponse *, id))success failure:(void (^)(NSError *))failure{
    
    NSDictionary *params = @{@"content":content,@"type":type,COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE};
    [self.mainNetwork cq_noCachePOST: URL_FOR_SUBMIT_SUGGESTION parameters: params
                             success:^(NSURLSessionDataTask *task, id responseObject) {
                                 if (success) {
                                     success(task.response, responseObject);
                                 }
                             } failure:^(NSURLSessionDataTask *task, NSError *error) {
                                 if (failure) {
                                     failure(error);
                                 }
                             }];
}

- (void)fetchSuggestionTypeSuccess:(void (^)(NSURLResponse *, id))success failure:(void (^)(NSError *))failure{
    
    [self.mainNetwork cq_noCacheGET: URL_FOR_FETCH_SUGGESTION_TYPE parameters: @{COMMON_REQUEST_DEVICE:COMMON_REQUEST_DEVICE_VALUE}
                            success:^(NSURLSessionDataTask *task, id resObj) {
                                if (success) {
                                    
                                    success(task.response, resObj);
                                }
                            } failure: ^(NSURLSessionDataTask *task, NSError *error) {
                                if (failure) {
                                    failure(error);
                                }
                            }];
}

@end
